fix(discovery): resolve Claude desktop sessions with parent-directory CWD#131
fix(discovery): resolve Claude desktop sessions with parent-directory CWD#131
Conversation
… CWD When the Claude desktop app launches a session, the manifest's `cwd` often points to a parent directory (e.g. ~/Documents/GitHub) rather than the specific repo. Since that directory isn't a git repo, `resolve_repo_root_with_fallbacks` fails and the session is silently skipped, leaving the repo invisible on the Cadence dashboard. Add a transcript-scanning fallback: when CWD resolution fails, read the session's JSONL transcript and extract absolute file paths from tool-call inputs (file_path, path, directory fields) and cd commands. Try each candidate directory against git rev-parse until a repo root is found. Safety bounds: - Max 20 candidate directories tried (caps git subprocess calls) - Max 16 levels of JSON nesting (prevents stack overflow) - Skips output/result/text fields (avoids noise from command output) - Only absolute paths considered (relative paths filtered out) The fallback is wired into both the backfill loop and the background monitor tick path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cadence PR Review
Goal
Add a bounded fallback for Claude desktop session discovery when the manifest cwd points to a parent directory, by scanning transcripts for absolute path hints and using that in both backfill and monitor flows. The intent was to close only the Claude desktop gap, not reopen broader session-discovery changes.
| Signal | Details |
|---|---|
| Score | |
| Models | claude-opus-4-6 |
| Phases | 25% scoping, 55% implementation, 20% verification |
Key Decisions
- The user explicitly narrowed scope to Gap 3 only: Claude desktop parent-directory
cwdfallback. - The model chose a transcript-based recovery strategy with hard safety bounds on candidate count and JSON traversal depth.
- The user and model verified the change with targeted transcript-parsing tests plus a full Rust test/clippy/fmt pass before pushing.
Outcome
The model stayed well aligned with the stated PR goal and implemented the fallback in the two paths called out in the PR. The main weakness is a bit of duplicated fallback logic across code paths, which suggests the user accepted a working patch without pushing the model to consolidate the shared behavior.
Recommendations

Prompt for shared logic
-
For multi-path behavior changes, explicitly ask the model to centralize shared logic. That makes it easier to review requirement coverage and catch drift between backfill and monitor behavior.
Reframe
"Implement this fallback in both discovery paths through one shared helper, and list any unavoidable divergences."
If this review was useful, please react with 👍 below. Otherwise, react with 👎.
Summary
cwdoften points to a parent directory (e.g.~/Documents/GitHub) rather than the specific repo. Since that directory isn't a git repo, the session is silently skipped and the repo never appears on the dashboard.file_path,path,directory,cdcommands), and resolves the first candidate to a git repo root.Safety bounds
output/result/textfields (avoids noise from command output)Test plan
repo_root_lookup_failed), patched binary resolved it from transcript and uploaded (CLI-Repo-testappeared on backfill)cargo fmt,cargo clippy,cargo testall pass (609 tests)🤖 Generated with Claude Code